package com.ewanghuiju.app.ui.main.activity;

import android.view.View;
import android.widget.RelativeLayout;

import com.ewanghuiju.app.R;
import com.ewanghuiju.app.base.BaseActivity;
import com.ewanghuiju.app.base.contract.main.InterestTagContract;
import com.ewanghuiju.app.model.bean.response.IntenestTagResponBean;
import com.ewanghuiju.app.presenter.main.InterestTagPresenter;
import com.ewanghuiju.app.test.bean.TestBean;
import com.ewanghuiju.app.ui.main.adapter.MyFlowTagAdapter;
import com.gyf.immersionbar.ImmersionBar;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.List;

import butterknife.BindView;

/**
 * @author sj  qq:751943509
 * @class 兴趣标签页面
 * @time 2020/2/14
 */
public class InterestTagActivity extends BaseActivity<InterestTagPresenter> implements InterestTagContract.View {

    @BindView(R.id.flowLayout)
    TagFlowLayout flowLayout;
    @BindView(R.id.toolbar)
    RelativeLayout toolbar;

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_interest_tag;
    }

    @Override
    protected void initEventAndData() {
        initTag();
    }

    private void initTag() {
        List<IntenestTagResponBean> list = TestBean.getIntenestTagResponBeanList();
        MyFlowTagAdapter myFlowTagAdapter = new MyFlowTagAdapter(list, mContext,3);
        flowLayout.setAdapter(myFlowTagAdapter);
        flowLayout.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
            @Override
            public boolean onTagClick(View view, int position, FlowLayout parent) {
                int status = list.get(position).getStatus();
                list.get(position).setStatus(status == 0 ? 1 : 0);
                myFlowTagAdapter.notifyDataChanged();
                return true;
            }
        });
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this)
                .titleBar(toolbar, true)
                .transparentBar()
                .statusBarDarkFont(true)
                .navigationBarDarkIcon(true)
                .init();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void showContent(String list) {

    }

    @Override
    public void showMoreContent(String list) {

    }
}
